package org.example.controller;

import org.example.domain.GoodsType;
import org.example.service.IGoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GoodsTypeController {

    @Autowired
    private IGoodsTypeService iGoodsTypeService;

    /**
     * 查询所有
     * @return
     */
    @RequestMapping("/findAll")
    public List<GoodsType> getAll(){
        List<GoodsType> list = iGoodsTypeService.list();
        return list;
    }

    /**
     * 新增或者修改
     * 如果有id就是修改 没有就i是新增
     * @param goodsType
     */
    @RequestMapping("/saveOrUpdate")
    public void saveOrUpdate(@RequestBody GoodsType goodsType){
        iGoodsTypeService.saveOrUpdate(goodsType);

    }
    @RequestMapping("/remove")
    public void remove(Integer id){
        //iGoodsTypeService.remove(new QueryWrapper<GoodsType>().eq("id",id));
        iGoodsTypeService.removeById(id);
    }
}
